feat(container-runner): sleep on startup idle timeout - #5586
Conversation
|
Stack for rivet-dev/actors
Get stack: change ontuyypk |
Review: feat(container-runner): sleep on startup idle timeoutOverall the change is well-scoped and the atomic one-shot Correctness: async fn on_sleep(self: Arc<Self>, ctx: Ctx<Self>) -> Result<()> {
if idle_timeout().is_some() {
self.stop_child(ctx.actor_id(), "actor sleeping (idle)").await;
} else {
self.drain_then_stop_child(ctx.actor_id(), "actor sleeping").await;
}
Ok(())
}
With this code, once an operator turns the feature on, every sleep of that actor for its whole life skips the drain and force-stops the child within Since if self.idle_state.load(Ordering::Relaxed) == IDLE_ARMED {
self.stop_child(ctx.actor_id(), "actor sleeping (idle)").await;
} else {
self.drain_then_stop_child(ctx.actor_id(), "actor sleeping").await;
}That only skips the drain when no request has ever arrived this generation (nothing to drain anyway), and preserves the full drain grace for every other sleep, matching the pre-existing behavior once the actor has actually been used. Minor: TOCTOU between the idle check and if this.idle_state.load(Ordering::Relaxed) == IDLE_REQUESTED {
return;
}
...
if let Err(err) = ctx.sleep() { ... }A request that arrives between the load and the Minor: undocumented env var
Test coverage No tests were added for the new behavior (timer arms/disarms correctly on first request, skip-drain vs. drain branching). Style Otherwise follows repo conventions well: hard tabs, structured tracing fields, complete-sentence comments, no em dashes, and |
aee8b0b to
ef4d957
Compare
102498a to
2e9fde1
Compare
ef4d957 to
d82ea5e
Compare
2e9fde1 to
5b11c04
Compare
No description provided.